﻿using Bomber.TF.Common.GDI;
using Bomber.TF.GameCenter.BombCenter;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Bomber.TF.GameCenter.BomberCenter
{
    [Species(SpeciesType.Bomber1)]
    public class Bomber1 : BomberBase
    {
        protected static ImageObject[] _iamges;
        static Bomber1()
        {
            Bitmap[] bitmaps = { Properties.Resources._1, Properties.Resources._2, Properties.Resources._3, Properties.Resources._4, Properties.Resources._5, Properties.Resources._6, Properties.Resources._7, Properties.Resources._8, Properties.Resources._9, Properties.Resources._10, Properties.Resources._11, Properties.Resources._13, Properties.Resources._14, Properties.Resources._15, Properties.Resources._16 };
            SetImages(bitmaps);
        }
        public Bomber1()
            : base(SpeciesType.Bomber1, new Size(43, 50))
        {
            var bomb = new Bomb1(this);
            base.SetBomb(bomb);

            base.Life = 1;
        }

        public override void Draw(Graphics g)
        {
            IntPtr hdc = g.GetHdc();
            var index = _playIndex;
            var img = _iamges[index];
            GDI32.DrawImageTransparenc(hdc, img.BitmapPtr, Location.X + (CellWidth - Size.Width >> 1), Location.Y, img.Width, img.Height, Size.Width, Size.Height);
            g.ReleaseHdc(hdc);
        }
        protected static void SetImages(Bitmap[] iamges)
        {
            ImageObject[] iamgesObj = new ImageObject[iamges.Length];
            for (int i = 0; i < iamges.Length; i++)
            {
                iamgesObj[i] = new ImageObject(iamges[i]);
            }
            SetImages(iamgesObj);
        }
        protected static void SetImages(ImageObject[] iamges)
        {
            _iamges = iamges;
        }
        protected override void DisposeAll()
        {
            base.DisposeAll();
            foreach (var i in _iamges)
            {
                i.Dispose();
            }
        }
    }
}
